#!/bin/sh

# 等待 MySQL 服务就绪
echo "Waiting for MySQL to be ready..."
while ! nc -z ct_mysql 3306; do
  sleep 1
done
echo "MySQL is ready"

# 运行数据库迁移
echo "Running database migrations..."
npm run production:migrate:mysql

# 启动应用
echo "Starting the application..."
pm2-runtime pm2.config.js